# Copyright (c) 2024 Bytedance Ltd. and/or its affiliates
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import matplotlib.pyplot as plt

# 你的数据
_data1 = {4: 0.17381612772379787, 6: 0.10311675440330001, 8: 0.0701606094392247, 10: 0.04628760877803369, 12: 0.025396883384183905, 14: 0.02165092398869654, 16: 0.011567344107814117, 18: 0.006278794553436143, 20: 0.002653338699936667, 22: 0.0018393022004938749, 24: 0.0012758540757955694, 26: 0.0016138638148312503, 28: 0.0008847561339347824, 30: 0.0006842214771265641, 32: 0.0005668473605460328, 34: 0.0005452372871143084, 36: 0.00043072494227361553, 38: 0.00048311725186781917, 40: 0.0005512011989283845, 42: 0.0005382811692043833, 44: 0.00024744656489556946, 46: 0.0001971471930487493, 48: 0.000252419825774728, 50: 0.0002406349955826, 52: 0.00034721789768178435, 54: 0.00022039276656983438, 56: 0.00011404316227673578, 58: 0.00017454566750131455, 60: 0.00014638358543206192, 62: 1.6849637749478e-05, 64: 0.00061441237249833, 3: 0.5165943595, 5: 0.9984671606666667, 7: 0.9943311723333332, 9: 0.9464150183333334, 11: 0.14760818027666667, 13: 0.004244168485, 15: 0.0007670498136666667, 17: 0.000478974941, 19: 0.00027702223193, 21: 0.00020378042951000003, 23: 0.000130212584, 25: 7.112645015e-05, 27: 4.722220681e-05, 29: 0.00011299381685, 31: 6.33913398e-05, 66: 6.42951248e-09, 68: 5.92445704e-09}
# _data2 = {4: 0.17221197762327659, 6: 0.10837434237576594, 8: 0.05581078701813828, 10: 0.020415392810085108, 12: 0.0037083366520860197, 14: 0.0015212774453215224, 16: 0.0006171941426609521, 18: 0.0003449669666436619, 20: 0.0002169081428386885, 22: 0.00018499523051089287, 24: 0.000186186513406383, 26: 0.0001698148659076923, 28: 0.00019477108841571428, 30: 0.00016787185125967743, 32: 0.00016712844024181997, 34: 0.00012533783558764, 36: 6.0519684272574205e-05, 38: 6.252267918779868e-05, 40: 8.703706516104385e-05, 42: 6.231815398162511e-05, 3: 0.5164727735166667, 5: 0.5451484659166667, 7: 0.40968673564999997, 9: 0.3324837111266667, 11: 0.38386442460032, 13: 0.20115722969108002, 15: 0.047048128064240004, 17: 0.00129075502216, 19: 0.000610327814775, 21: 4.818778533333333e-05, 23: 5.25298049e-05, 44: 1.872540243016549e-05, 46: 6.656091048056998e-06, 48: 5.345049534116514e-06, 50: 9.437757163400999e-07, 52: 5.1466249232897495e-06, 54: 3.6791756172e-06, 56: 6.39096553e-11, 58: 5.80018256e-11, 60: 1.2349255e-10, 62: 1.86571203e-10, 64: 6.58009203e-11, 25: 9.088009921500001e-06, 27: 2.74197713248e-05, 29: 3.40517458665e-05, 31: 7.60568238e-06, 33: 8.69699872e-07, 35: 2.58372752e-07, 37: 2.03791844e-07, 39: 2.62898592e-11, 41: 1.27402533e-11, 43: 3.543001e-09, 45: 1.57056405e-07, 47: 1.72877268e-11}
# _data3 = {4: 0.17370279450998935, 6: 0.10084246841039782, 8: 0.05041381487045163, 10: 0.028518101865045463, 12: 0.003690199486590909, 14: 0.00136263164097093, 16: 0.0008469952841279069, 18: 0.0006183755614109412, 20: 0.0003117164402527381, 22: 0.00023524252367493667, 24: 0.00018184914286763167, 26: 0.00015814965226407894, 28: 0.00018482565382477536, 30: 0.00016199368035515902, 32: 0.0001228727492422016, 34: 9.817186608143528e-05, 36: 8.927107411500139e-05, 38: 5.8736690785440705e-05, 40: 4.378514779331969e-05, 42: 3.490261850666347e-05, 44: 1.4396188957633807e-05, 46: 5.012504139797999e-06, 48: 2.5379099978662746e-06, 50: 7.195290088566421e-06, 52: 7.440366346686438e-07, 54: 5.159488582625295e-07, 56: 7.161742348383701e-08, 58: 2.188431612934241e-06, 60: 2.086806753296392e-06, 62: 3.409272971708581e-06, 3: 0.5161750853833333, 5: 0.998370751, 7: 0.9968938083333333, 9: 0.5027935176666666, 11: 0.1436820435, 13: 0.12786827015333332, 15: 0.0037987686233333334, 17: 0.004607193496666667, 19: 0.0009658570976666666, 21: 0.0005482542973333334, 23: 0.0003934085846666667, 25: 0.0003181119426666666, 27: 0.0001372537553, 29: 0.0001553416785333333, 31: 0.0003121780863333333, 33: 0.000248232493345, 35: 0.0002295280654346333, 37: 0.00016557107921476668, 39: 9.1820308332941e-05, 41: 7.581503095533333e-05, 43: 8.623206257691038e-05, 45: 1.0461426275238e-06, 47: 6.958440909491668e-07, 49: 2.568459319715e-07, 51: 5.77909985285e-08, 53: 1.2422218795000002e-10, 55: 9.372241890000001e-11, 64: 6.017863224023346e-06, 66: 1.9681181321307594e-06, 68: 1.7770958778666665e-10, 70: 2.950172052749999e-11, 72: 9.992028042499999e-11, 74: 2.0074645633333335e-11, 76: 2.40251152e-11, 78: 2.86065616e-11, 80: 2.91229263e-11} 
_data2 = {4: 0.17411610375295733, 6: 0.09903257283401107, 8: 0.0629965389029773, 10: 0.04223477584889771, 12: 0.0301657991389885, 14: 0.02146384786490588, 16: 0.012642258361665477, 18: 0.005604397190130956, 20: 0.004661873723699999, 22: 0.004006514651142683, 24: 0.0022078661890225, 26: 0.0017205065125886069, 28: 0.001973113440091053, 30: 0.0015114689945195943, 32: 0.0016503274476872907, 34: 0.0019830572543900497, 36: 0.014088313905436767, 38: 0.016308216106491913, 40: 0.017227806112365227, 42: 0.00028434236561784956, 44: 0.0002792256079563561, 46: 0.00027845279451239337, 48: 0.0003082742414410693, 50: 0.0001357387737844184, 52: 6.290040795219761e-05, 54: 6.174238762031655e-05, 56: 7.910591313049293e-05, 58: 0.00011356515570949193, 60: 0.00010494266120430347, 62: 5.214606062869598e-05, 64: 8.525287028267941e-05, 66: 1.4657894615618499e-05, 68: 2.90934771893e-08, 70: 9.850931165e-11, 72: 5.987105255e-11, 3: 0.5155348909166667, 5: 0.998061672, 7: 0.9968435763333333, 9: 0.9814835216666666, 11: 0.5201618986666666, 13: 0.0357510003, 15: 0.06490373518666667, 17: 0.0031291247209999998, 19: 0.000691451243, 21: 0.0004110284396666667, 74: 3.94521082e-11, 23: 0.00025542821264999997, 25: 0.0002058307705, 27: 0.00022587229550000002, 29: 0.00015776813700000002, 31: 0.000238016987, 33: 0.00023687321750000002, 35: 0.000284419352, 37: 0.000361376226, 39: 0.000419542992, 41: 0.0001510641545, 43: 4.771932395e-05, 45: 0.00018760266424999999, 47: 1.44544158e-05, 49: 3.29968733e-05, 51: 3.36646312e-05}
_data3 = {4: 0.17448433905361704, 6: 0.09437166590688166, 8: 0.06476272781972828, 10: 0.04660350080438046, 12: 0.03063742472216484, 14: 0.023385817622877766, 16: 0.01688643120103371, 18: 0.013246240224790696, 20: 0.0066721125219559516, 22: 0.0036231982751374994, 24: 0.005688292554835375, 26: 0.0018014504171900004, 28: 0.0018867607560497331, 30: 0.0015058798527415275, 32: 0.001145708494517858, 34: 0.0008047629067784851, 36: 0.0005337920516394532, 38: 0.0005429737280890002, 40: 0.0006655192173484549, 42: 0.0003818009714553385, 44: 0.0001912109188565034, 46: 0.00018797688811930034, 48: 0.0001972136511560245, 50: 0.0002263835304830098, 52: 0.0001340618565165575, 54: 0.0001314421811892365, 56: 0.00010346822698295522, 58: 0.0006967118834620793, 60: 5.40917801933784e-05, 62: 0.00015315509751173475, 64: 2.330655929642656e-05, 66: 1.96294100480681e-05, 3: 0.5165487465999999, 5: 0.9982935746666667, 7: 0.9963586903333334, 9: 0.988139313, 11: 0.984135466, 13: 0.374905268, 15: 0.32376272416, 17: 0.01506438428, 19: 0.004066035891666667, 21: 0.006098458136666668, 23: 0.0013928234273333333, 25: 0.002233261828, 68: 4.144987289333333e-08, 70: 4.12353585e-05, 72: 5.79418735e-11, 27: 0.00031286709555, 29: 4.020519235e-05, 31: 9.987687769999999e-05, 33: 0.000147276068, 35: 0.000161469769, 37: 8.30428412e-05, 39: 4.63053821e-05, 41: 1.05141895e-10}
data1 = {}
data2 = {}
data3 = {}
for k in _data1:
    if k % 2 == 0:
        data1[k] = _data1[k]
for k in _data2:
    if k % 2 == 0:
        data2[k] = _data2[k]
for k in _data3:
    if k % 2 == 0:
        data3[k] = _data3[k]

# 分别获取字典的键和值，作为横坐标和纵坐标
x1 = list(data1.keys())
y1 = list(data1.values())

x2 = list(data2.keys())
y2 = list(data2.values())


x3 = list(data3.keys())
y3 = list(data3.values())

plt.plot(x3, y3, marker='^', label='iter 27w', markersize=4)

# 绘制曲线图
plt.plot(x1, y1, marker='o', label='iter 9w', markersize=4)

# 绘制第二组数据
plt.plot(x2, y2, marker='s', label='iter 18w', markersize=4)


# 添加标题和坐标轴标签
plt.title('Data Plot')
plt.xlabel('Step')
plt.ylabel('Win rate')

plt.yscale('log')
# 显示网格
plt.grid(True)

# 显示图例
plt.legend()

# 显示图形
plt.savefig('/opt/tiger/data_plot.png', dpi=300) 

plt.close()